# Makefile for Docker Nginx PHP Composer MySQL

include .env

help:
	@echo ""
	@echo "使用: make [命令]"
	@echo "例如: make docker-start"
	@echo ""
	@echo "可用命令:"
	@echo "  clean               清空项目文件进行重置（含数据库）"
	@echo "  composer-up         使用composer安装项目依赖"
	@echo "  docker-start        创建并启动所有项目容器（nginx、mysql、php）"
	@echo "  docker-stop         停止容器并重置所有数据（警告！会删除所有文件及数据库！）"
	@echo "  logs                查看容器日志"

clean:
	@rm -Rf ./data/mysql
	@rm -Rf ./web
	@rm -Rf ./log
	@rm -Rf ./etc/ssl/*

composer-up:
	@docker exec -i php composer install

docker-start: init
	@mkdir web
	@tar -xzf releases/office-v5.6.8.tar.gz -C web
	@mv web/office-v5.6.8/* web/
	@mv web/office-v5.6.8/.[^.]* web/
	@rm -rf web/office-v5.6.8
	@docker-compose up -d

docker-stop:
	@docker-compose down -v
	@make clean

logs:
	@docker-compose logs -f

resetOwner:
	@$(shell chown -Rf $(WWW_DATA_UID):$(shell id -g -n $(WWW_DATA_UID)) "$(shell pwd)/data/backup" "$(shell pwd)/etc/ssl" "$(shell pwd)/web" 2> /dev/null)

.PHONY: clean init